function isEmail(str) {
    const reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
    return reg.test(str);
}

function isValidUsername(str) {
    const reg = /^([a-zA-Z]|_)([a-zA-Z]|[0-9]|_){0,9}$/;
    return reg.test(str);
}

function isValidPassword(str) {
    return str.length >= 8 && str.length <= 16;
}

function isValidRePassword(str1, str2) {
    return str1 === str2;
}

function isValidPhone(str) {
    const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    return reg.test(str);
}
function submit() {
    let Myform = document.getElementById("Myform");
    let email = document.getElementById("email").value;
    let username = document.getElementById("username").value;
    let password = document.getElementById("password").value;
    let rePassword = document.getElementById("rePassword").value;
    let phone = document.getElementById("phone").value;
    let res = "";
    if (!isEmail(email)) {
        res += "邮箱格式错误!\n";
    }
    if (!isValidUsername(username)) {
        res += "用户名输入错误!\n";
    }
    if (!isValidPassword(password)) {
        res += "密码长度不符合要求!\n";
    }
    if (!isValidRePassword(password, rePassword)) {
        res += "两次密码输入不一致!\n";
    }
    if (!isValidPhone(phone)) {
        res += "手机号输入不正确!\n";
    }
    if (res !== "") {
        alert(res);
    } else {
        alert("提交成功!");
        Myform.submit();
    }
}
